package gam.t1.appraisal2;

import com.google.common.collect.Maps;
import gam.t1.appraisal2.dinv.DataInventory;
import gam.t1.appraisal2.dinv.impl.AppraisalDataInventory;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import pers.neige.neigeitems.manager.ItemManager;
import pers.neige.neigeitems.manager.ItemPackManager;

import java.util.Map;
import java.util.UUID;

public final class Data {
    public static final ItemStack EMPTY = new ItemStack(Material.AIR);

    public static final ItemManager NI_ITEMMANAGER;
    public static final ItemPackManager NI_ITEMPACKMANAGER;
    private static final Map<UUID, Inventory> NI_IN = Maps.newLinkedHashMap();
    private static final Map<UUID, DataInventory> NI_DATA = Maps.newLinkedHashMap();
    public static final Map<String,AppraisalDataInventory> APPRAISAL_DATA_INVENTORIES = Maps.newHashMap();
    static {
        NI_ITEMMANAGER = ItemManager.INSTANCE;
        NI_ITEMPACKMANAGER = ItemPackManager.INSTANCE;
    }
    public static DataInventory getAppraisalDataInventory(UUID uuid) {
        return NI_DATA.get(uuid);
    }
    public static void addAppraisalDataInventory(UUID uuid, DataInventory dataInventory) {NI_DATA.put(uuid, dataInventory);}
    public static Player getPlayerByDataInventory(DataInventory di){
        for (UUID uuid : NI_DATA.keySet()) {
            if (NI_DATA.get(uuid).equals(di)){
                return Bukkit.getPlayer(uuid);
            }
        }
        return null;
    }
    public static Inventory getInventory(UUID uuid) {
        return NI_IN.get(uuid);
    }
    public static void addInventory(UUID uuid, Inventory inventory) {
        NI_IN.put(uuid, inventory);
    }
    public static void removeInventory(UUID uuid) {
        NI_IN.remove(uuid);
    }
    public static void removeAppraisalDataInventory(UUID uuid){
        NI_DATA.remove(uuid);
    }
}
